package com.huatai.model.entity;

import com.huatai.model.config.TreeNodeConfig;

import java.io.Serializable;
import java.util.HashMap;
import java.util.List;

/**
 *  TreeNodeMap类
 * @author yukun
 * @Date 2020/4/21 16:04
 * @param
 * @return
 * @package
 */
public class TreeNodeMap extends HashMap implements Serializable {

    private static final long serialVersionUID = 8376668307601977428L;

    private TreeNodeConfig treeNodeConfig;

    public TreeNodeMap(){
        this.treeNodeConfig = TreeNodeConfig.getDefaultConfig();
    }

    public TreeNodeMap(TreeNodeConfig treeNodeConfig){
        this.treeNodeConfig = treeNodeConfig;
    }

    public <T> T getId() {
        return (T)super.get(treeNodeConfig.getIdKey());
    }

    public void setId(String id) {
        super.put(treeNodeConfig.getIdKey(), id);
    }

    public <T> T getParentId() {
        return (T)super.get(treeNodeConfig.getParentIdKey());
    }

    public void setParentId(String parentId) {
        super.put(treeNodeConfig.getParentIdKey(), parentId);
    }

    public <T> T getTitle() {
        return (T)super.get(treeNodeConfig.getNameKey());
    }

    public void setTitle(String name) {
        super.put(treeNodeConfig.getNameKey(), name);
    }

    public <T> T getType() {
        return (T)super.get(treeNodeConfig.getTypeKey());
    }

    public void setType(String type) {
        super.put(treeNodeConfig.getTypeKey(), type);
    }

    public <T> T  getCode() {
        return (T)super.get(treeNodeConfig.getCodeKey());
    }

    public TreeNodeMap setCode(String code) {
        super.put(treeNodeConfig.getCodeKey(), code);
        return this;
    }

    public List<TreeNodeMap> getChildren() {
        return (List<TreeNodeMap>)super.get(treeNodeConfig.getChildrenKey());
    }

    public void setChildren(List<TreeNodeMap> children) {
        super.put(treeNodeConfig.getChildrenKey(),children);
    }

    public void extra(String key,Object value){
        super.put(key,value);
    }

}
